package com.hh.vrserver.web.vo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;

/**
 * @author yeweijun
 * @version 1.0 2023/7/5 09:52
 */
@AllArgsConstructor
@Getter
@ToString
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class VrDataVo {
    private String keyId;
    private Long id;
    private Boolean encrypted;
    private String[] dr;
    private String remark;
    private String password;

    public List<LocalDate> getDateRange() {
        List<LocalDate> dd = new ArrayList<>();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        if (dr != null && dr.length == 2) {
            dd.add(LocalDate.parse(dr[0], formatter));
            dd.add(LocalDate.parse(dr[1], formatter));
        } else {
            dd.add(null);
            dd.add(null);
        }
        return dd;
    }
}
